package com.yuesystem.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yuesystem.common.BaseContext;
import com.yuesystem.common.R;
import com.yuesystem.entity.AcademyItem;
import com.yuesystem.entity.ChangeItem;
import com.yuesystem.entity.User;
import com.yuesystem.service.AcademyItemService;
import com.yuesystem.service.ChangeItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;

@RestController
@RequestMapping("/changes")
@Slf4j
public class ChangeItemController {
    @Autowired
    private ChangeItemService changeItemService;

    @Autowired
    private AcademyItemService academyItemService;


    /**
     * 新增编辑条目
     * @param academyItem
     * @return
     */
    @PostMapping("/add")
    public R<String> add(@RequestBody AcademyItem academyItem) {
        //获取当前用户的信息
        Long userId = BaseContext.getCurrentId();
        changeItemService.addItem(academyItem, userId);
        return R.success("添加条目成功！");
    }


//    /**
//     * 通过某个书院条目ID删除某个条目
//     * @param itemId
//     * @return
//     */
//    @DeleteMapping("/delete/{itemId}")
//    public R<String> delete(@PathVariable Long itemId){
//        //根据书院获得具体的书院条目信息
//        AcademyItem academyitem = academyItemService.getById(itemId);
//
//        //获得当前用户信息
//        Long userId = BaseContext.getCurrentId();
//
//        changeItemService.deleteItem(academyitem,userId);
//    }



}
